package com.example.myapplication.databinding


import android.os.Bundle
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import com.example.myapplication.base.BaseActivity
import com.example.myapplication.base.MainApplication
import com.example.myapplication.R

class DataBindingActivity : BaseActivity() {

    private lateinit var binding: com.example.myapplication.databinding.LayoutDataBindingBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this, R.layout.layout_data_binding)
        val user = User(1, "测试事件绑定")
        binding.userBean = user

        val userEx = UserEx()
        binding.userBeanEx = userEx


        binding.listener = Listener()

    }



}

class Listener {
    fun change(user : User) {
        Toast.makeText(MainApplication.context, "触发事件", Toast.LENGTH_SHORT).show()
    }
}